# $Id: PKGBUILD 470 2011-11-09 12:55:50Z pupykins $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=firefox-xmarks
pkgver=4.0.2
pkgrel=2
pkgdesc="plugin for firefox which synchronizes bookmarks and passwords"
arch=('any')
url="http://www.xmarks.com/"
license=('custom')
depends=("firefox")
makedepends=('unzip')
source=(https://static.xmarks.com/clients/firefox/xmarks-$pkgver-release.xpi)
md5sums=('0efc66608390f1e83865bfc46d0025d2')

build() {
    cd $srcdir
    #this method comes from gentoo (http://kambing.ui.edu/gentoo-portage/eclass/mozextension.eclass):
    local emid=$(sed -n -e '/<\?em:id>\?/!d; s/.*\([\"{].*[}\"]\).*/\1/; s/\"//g; p; q' install.rdf)
    local dstdir=$pkgdir/usr/lib/firefox/extensions/${emid}
    mkdir -p $pkgdir/usr/share/licenses/$pkgname/
    install -d $dstdir
    sed -i 's#<em:maxVersion>.*</em:maxVersion>#<em:maxVersion>99.*</em:maxVersion>#' install.rdf
    cp -R * $dstdir
    rm $dstdir/xmarks-$pkgver-release.xpi

    cat <<EOF >$pkgdir/usr/share/licenses/$pkgname/license
Copyright 2009 XMarks, Inc.  All Rights Reserved.
EOF
}
